/**
 * 
 */
package com.icss.ah.share.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.icss.ah.base.bean.EasyuiDataGridJson;

/**
 * @author qushuangshuang
 *
 */
@Service
@Transactional
public class UserShareStatisticsService {
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	private final Logger errlog = Logger.getLogger(UserShareStatisticsService.class);
	private final Logger infolog = Logger.getLogger(UserShareStatisticsService.class);
	
	public EasyuiDataGridJson queryStatisticsByUserCode(Map<String, Object> map) {
		EasyuiDataGridJson dataGridJson = new EasyuiDataGridJson();
		try {
			List<Map<String, Object>> rows = sqlSessionTemplate.selectList("UserShareStatisticsMapper.queryStatisticsByUserCode", map);
			Long total = sqlSessionTemplate.selectOne("UserShareStatisticsMapper.queryStatisticsCount", map);
			dataGridJson.setRows(rows);
			dataGridJson.setTotal(total);
			infolog.info("UserShareStatistics| queryStatisticsByUserCode|para:" + map);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("UserShareStatistics| queryStatisticsByUserCode", e);
		}
		return dataGridJson;
	}
	
	public Long  queryCount(Map<String, Object> map) {
		return sqlSessionTemplate.selectOne("UserShareStatisticsMapper.queryStatisticsCount", map);
		
	}
	
	public List<Map<String, Object>> queryStatisticsAll(Map<String, Object> map) {
		try {
			List<Map<String, Object>> rows = sqlSessionTemplate.selectList("UserShareStatisticsMapper.queryStatisticsByUserCode", map);
			infolog.info("UserShareStatistics| queryStatisticsByUserCode|para:" + map);
			return  rows;
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("UserShareStatistics| queryStatisticsByUserCode", e);
			return  new ArrayList<>();
		}
		
	}
}
